<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Gloze: xsi:type</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Gloze
   &#160;<span id="projectnumber">1.01-beta2</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">xsi:type </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p>The XML schema instance namespace defines xsi:type allowing elements be be explicitly annotated with type information. This can be used as an alternative mechanism to substitution groups, but also provides a way to jump back into a schema from within xs:any content. An example of this is shown below using an XML document that has no schema.</p>
<p>The document element 'myLink' is not defined in the schema, so is processed as if it were subject to xs:any and a default no-schema mapping is employed. This unidentified element is treated as unqualified and is defined in the default namespace set by the xmlns parameter.</p>
<p>The link schema doesn't define the 'myLink' element, but it does define the 'SimpleLink' content. The XML instance refers to this using an xsi:type attribute. The RDF mapping for this generates a corresponding rdf:type statement. The content of 'myLink' is then processed according to the content model of 'SimpleLink', so we have escaped from the xs:any no-schema mapping.</p>
<div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;myLink xmlns:eg=<span class="stringliteral">&quot;http://example.org/&quot;</span> xmlns:xlink=<span class="stringliteral">&quot;http://www.w3.org/1999/xlink&quot;</span>
        xmlns:xsi=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> xsi:type=<span class="stringliteral">&quot;eg:SimpleLink&quot;</span>
        xlink:href=<span class="stringliteral">&quot;foo.xml&quot;</span> /&gt;

</pre></div> <div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;xs:schema xmlns:xs=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema&quot;</span>
        targetNamespace=<span class="stringliteral">&quot;http://example.org/&quot;</span> xmlns:xlink=<span class="stringliteral">&quot;http://www.w3.org/1999/xlink&quot;</span>&gt;
        &lt;xs:<span class="keyword">import</span> <span class="keyword">namespace</span>=<span class="stringliteral">&quot;http://www.w3.org/1999/xlink&quot;</span> schemaLocation=<span class="stringliteral">&quot;xlink.xsd&quot;</span> /&gt;

        &lt;xs:complexType name=<span class="stringliteral">&quot;SimpleLink&quot;</span>&gt;
                &lt;xs:attributeGroup ref=<span class="stringliteral">&quot;xlink:simpleLink&quot;</span>/&gt;
        &lt;/xs:complexType&gt;

&lt;/xs:schema&gt;
</pre></div><p>The use of the 'SimpleLink' content model is evidenced by the correct datatyping of the xlink:href and the insertion of the xlink:type implied by the xlink attribute group.</p>
<div class="fragment"><pre class="fragment">@prefix ns2:     &lt;http:<span class="comment">//example.org/&gt; .</span>
@prefix ns1:     &lt;http:<span class="comment">//example.org/def/&gt; .</span>
@prefix eg:      &lt;http:<span class="comment">//example.org/&gt; .</span>
@prefix xlink_:  &lt;http:<span class="comment">//www.w3.org/1999/xlink#&gt; .</span>
@prefix xs_:     &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema#&gt; .</span>
@prefix xlink:   &lt;http:<span class="comment">//www.w3.org/1999/xlink&gt; .</span>
@prefix rdf:     &lt;http:<span class="comment">//www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .</span>
@prefix xs:      &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema&gt; .</span>

&lt;http:<span class="comment">//example.org/linkType.xml&gt;</span>
      ns1:myLink
              [ a       eg:SimpleLink ;
                xlink_:href <span class="stringliteral">&quot;http://example.org/foo.xml&quot;</span>^^xs_:anyURI ;
                xlink_:type <span class="stringliteral">&quot;simple&quot;</span>^^xs_:string
              ] .
</pre></div><dl class="see"><dt><b>See also:</b></dt><dd><a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a> </dd></dl>
</div></div>


<hr class="footer"/><address class="footer"><small>
Generated on Tue Nov 15 2011 22:13:50 for Gloze by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
